package com.zhonghui.dc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhonghui.common.annotation.Log;
import com.zhonghui.common.core.controller.BaseController;
import com.zhonghui.common.core.domain.AjaxResult;
import com.zhonghui.common.enums.BusinessType;
import com.zhonghui.dc.domain.DcEnergyConsumption;
import com.zhonghui.dc.service.IDcEnergyConsumptionService;
import com.zhonghui.common.utils.poi.ExcelUtil;
import com.zhonghui.common.core.page.TableDataInfo;

/**
 * 智造双碳—双碳管理—能耗数据采集Controller
 * 
 * @author qiezi
 * @date 2023-12-25
 */
@RestController
@RequestMapping("/dc/consumption")
public class DcEnergyConsumptionController extends BaseController
{
    @Autowired
    private IDcEnergyConsumptionService dcEnergyConsumptionService;

    /**
     * 查询智造双碳—双碳管理—能耗数据采集列表
     */
    @PreAuthorize("@ss.hasPermi('dc:consumption:list')")
    @GetMapping("/list")
    public TableDataInfo list(DcEnergyConsumption dcEnergyConsumption)
    {
        startPage();
        List<DcEnergyConsumption> list = dcEnergyConsumptionService.selectDcEnergyConsumptionList(dcEnergyConsumption);
        return getDataTable(list);
    }

    /**
     * 导出智造双碳—双碳管理—能耗数据采集列表
     */
    @PreAuthorize("@ss.hasPermi('dc:consumption:export')")
    @Log(title = "智造双碳—双碳管理—能耗数据采集", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DcEnergyConsumption dcEnergyConsumption)
    {
        List<DcEnergyConsumption> list = dcEnergyConsumptionService.selectDcEnergyConsumptionList(dcEnergyConsumption);
        ExcelUtil<DcEnergyConsumption> util = new ExcelUtil<DcEnergyConsumption>(DcEnergyConsumption.class);
        util.exportExcel(response, list, "智造双碳—双碳管理—能耗数据采集数据");
    }

    /**
     * 获取智造双碳—双碳管理—能耗数据采集详细信息
     */
    @PreAuthorize("@ss.hasPermi('dc:consumption:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dcEnergyConsumptionService.selectDcEnergyConsumptionById(id));
    }

    /**
     * 新增智造双碳—双碳管理—能耗数据采集
     */
    @PreAuthorize("@ss.hasPermi('dc:consumption:add')")
    @Log(title = "智造双碳—双碳管理—能耗数据采集", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DcEnergyConsumption dcEnergyConsumption)
    {
        return toAjax(dcEnergyConsumptionService.insertDcEnergyConsumption(dcEnergyConsumption));
    }

    /**
     * 修改智造双碳—双碳管理—能耗数据采集
     */
    @PreAuthorize("@ss.hasPermi('dc:consumption:edit')")
    @Log(title = "智造双碳—双碳管理—能耗数据采集", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DcEnergyConsumption dcEnergyConsumption)
    {
        return toAjax(dcEnergyConsumptionService.updateDcEnergyConsumption(dcEnergyConsumption));
    }

    /**
     * 删除智造双碳—双碳管理—能耗数据采集
     */
    @PreAuthorize("@ss.hasPermi('dc:consumption:remove')")
    @Log(title = "智造双碳—双碳管理—能耗数据采集", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dcEnergyConsumptionService.deleteDcEnergyConsumptionByIds(ids));
    }
}
